<?php

class CommentTable extends Doctrine_Table
{
  public function getBackendListQuery(Doctrine_Query $query)
  {
    $rootAlias = $query->getRootAlias();

    $query->leftJoin("$rootAlias.article a")
      ->leftJoin("$rootAlias.author u");

    $user = sfContext::getInstance()->getUser();
    if (!$user->hasCredential('super')) 
    {
      $query->innerJoin('a.publisher p')
        ->andWhere('p.id = ?', $user->getAttribute('admin_id'));
    }
    
    return $query;
  }
}
